package com.lxmes.base.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.base.domain.JcIteminfoJs;
import com.lxmes.base.service.IJcIteminfoJsService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 物料号转换计算Controller
 * 
 * @author 张志煜
 * @date 2023-01-10
 */
@RestController
@RequestMapping("/base/iteminfoJs")
public class JcIteminfoJsController extends BaseController
{
    @Autowired
    private IJcIteminfoJsService jcIteminfoJsService;

    /**
     * 查询物料号转换计算列表
     */
    @PreAuthorize("@ss.hasPermi('base:iteminfoJs:list')")
    @GetMapping("/list")
    public TableDataInfo list(JcIteminfoJs jcIteminfoJs)
    {
        startPage();
        List<JcIteminfoJs> list = jcIteminfoJsService.selectJcIteminfoJsList(jcIteminfoJs);
        return getDataTable(list);
    }

    /**
     * 导出物料号转换计算列表
     */
    @PreAuthorize("@ss.hasPermi('base:iteminfoJs:export')")
    @Log(title = "物料号转换计算", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JcIteminfoJs jcIteminfoJs)
    {
        List<JcIteminfoJs> list = jcIteminfoJsService.selectJcIteminfoJsList(jcIteminfoJs);
        ExcelUtil<JcIteminfoJs> util = new ExcelUtil<JcIteminfoJs>(JcIteminfoJs.class);
        util.exportExcel(response, list, "物料号转换计算数据");
    }

    /**
     * 获取物料号转换计算详细信息
     */
    @PreAuthorize("@ss.hasPermi('base:iteminfoJs:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(jcIteminfoJsService.selectJcIteminfoJsById(id));
    }

    /**
     * 新增物料号转换计算
     */
    @PreAuthorize("@ss.hasPermi('base:iteminfoJs:add')")
    @Log(title = "物料号转换计算", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JcIteminfoJs jcIteminfoJs)
    {
        return toAjax(jcIteminfoJsService.insertJcIteminfoJs(jcIteminfoJs));
    }

    /**
     * 修改物料号转换计算
     */
    @PreAuthorize("@ss.hasPermi('base:iteminfoJs:edit')")
    @Log(title = "物料号转换计算", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JcIteminfoJs jcIteminfoJs)
    {
        return toAjax(jcIteminfoJsService.updateJcIteminfoJs(jcIteminfoJs));
    }

    /**
     * 删除物料号转换计算
     */
    @PreAuthorize("@ss.hasPermi('base:iteminfoJs:remove')")
    @Log(title = "物料号转换计算", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jcIteminfoJsService.deleteJcIteminfoJsByIds(ids));
    }
}
